package cn.com.cetccst.compliancecheck.checker;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

import cn.com.cetccst.compliancecheck.R;
import cn.com.cetccst.tools.log.CommonLogger;
import cn.com.cetccst.tools.pm.AppPackage;

public class ApplicationChecker extends Checker {

    private static ApplicationChecker instance;
    private ApplicationChecker(Context context) {
        super(CheckerType.Application);
        name = context.getString(R.string.compliance_black_list);
    }

    public static void init(Context context) {
        if(instance == null) {
            instance = new ApplicationChecker(context);
        }
    }

    public static ApplicationChecker getInstance() {
        return instance;
    }

    @Override
    public void check(Context context) {
        CommonLogger.info("Start check applications");
        super.check(context);
        if(!isEnable())
            return;
        //TODO 后续从数据库中获取，动态监听软件的安装并判断__________________________________
        List<String> appBlackList = new ArrayList<>();
        for (String blackApp : appBlackList) {
            if (AppPackage.isPackageFound(context, blackApp)) {
                setResult(CheckResult.Violated);
            }
        }
        setResult(CheckResult.Pass);
    }

}
